package hp.com.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import hp.com.entity.Car;
import hp.com.entity.Order;
import hp.com.entity.User;
import hp.com.mapper.UserMapper;

@Service
public class UserServiceImpl implements UserService {
	@Autowired
	private UserMapper mapper;

	//登陆
	public User login(User user) {
		User u = mapper.login(user);
		return u;
	}

	//注册前的查询
	public User selectByName(User user) {
		User u = mapper.selectByName(user);
		return u;
	}

	//注册
	public int zhuce(User user) {
		int a = mapper.zhuce(user);
		return a;
	}

	//个人信息管理(个人信息修改)
	public int yupdate(User user) {
		int a = mapper.yupdate(user);
		return a;
	}
	//个人订单的查询
	public List<Order> dingdan(User user) {
		List<Order> list = mapper.dingdan(user);
		return list;
	}

	//汽车租赁
	public List<Car> zulin() {
		List<Car> list = mapper.zulin();
		return list;
	}

	//汽车租赁中的判断用户的信息是否完善
	public User panduan(String unamename) {
		User panduan = mapper.panduan(unamename);
		return panduan;
	}

	//租赁汽车的回显
	public Car zuselectbyid(Integer cid) {
		Car c = mapper.zuselectbyid(cid);
		return c;
	}

	//租赁成功用户余额减少
	public int updateUser(User user) {
		int a = mapper.yupdate(user);
		return a;
	}

	//租车订单的添加
	public int insertDing(Order order) {
		int a = mapper.insertDing(order);
		return a;
	}

	//租车只能租一辆的判断
	public List<Order> zushu(User user) {
		List<Order> list = mapper.zushu(user);
		return list;
	}

	//还车的订单查询
	public List<Order> selecthuanche(User user) {
		List<Order> list = mapper.zushu(user);
		return list;
	}

	//充值
	public int chongzhi(User user) {
		int a = mapper.chongzhi(user);
		return a;
	}

	//还车 订单的修改
	public int updateDingdan(Order order) {
		int a = mapper.updateDingdan(order);
		return a;
	}

	//修改汽车状态
	public int updatecar(Car car) {
		int a = mapper.updatecar(car);
		return a;
	}

}
